<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>网络文件下载</title>
    <link rel="stylesheet" href="../../css/theme.css"/>

    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
            text-align: center;
        }
        .addr {
            font-size: 3vw;
            min-width: 90%;
            max-width: 90%;
            min-height: 15vw;
            margin-top: 5vw;
        }
        .btn {
            font-size: 3vw;
            width: 20vw;
        }

        button {
            font-size: 3vh;
            margin: 2vh;
            border-width: 0.5vh;
        }

    </style>
</head>
<body>

    <textarea id="addr" class="addr" placeholder="文件链接"></textarea>
    <br><br><br><br>
    <button class="btn" type="button" onclick="down()">下载</button>

<script src="../../js/config.js"></script>
<script>

    function down() {
        let addr = document.getElementById('addr').value.trim();
        let fileName = 'fileName';
        try {
            let split = new URL(addr).pathname.split('/')
            fileName = split[split.length - 1]
        } catch (e) {
            alert(e);
            ev.preventDefault();
            return false;
        }
        window.open(Global.apiPath + `/network/downloadFile/${fileName}?${addr}`);
        return true;
    }
</script>
</body>
</html>